package com.example.demo.dao;

import com.example.demo.domain.Resource;
import com.example.demo.support.CustomRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;

import java.util.List;

@RepositoryRestResource(path = "resource")
public interface ResourceRepository extends CustomRepository<Resource,Long> {
    Resource findById(long id);

    @Query("select r from Resource r where r.Parent= :Parent")
    List<Resource> findChildsByParent(@Param("Parent") Resource r);

    @Query("select r from Resource r where r.Name like :name")
    List<Resource> findByNameLike(@Param("name") String name);


//
//
//    @RestResource(path = "nameStartsWith", rel = "nameStartsWith")
//    Resource findByNameStartsWith(@Param("Name")String name);
}
